<include file="common/header_dc" title="矿机钱包提转" body=""/>
<div class="page">
    <div class="page-hd">
        <div class="header">
            <div class="header-left">
                <a href="javascript:history.go(-1)" class="left-arrow"></a>
            </div>
            <div class="header-title">矿机钱包提转</div>
            <div class="header-right">
                <a href="#"></a>
            </div>
        </div>
    </div>

    <div class="page-bd">
        <!-- 页面内容-->
        <form method="post" id="payform">
            <div class="weui-cells weui-cells_form">
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">可提转数量</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="text" disabled id="minners" value="{$info.miner}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">提取数量</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="text" id="tqNumber" name="tqNumber" onkeyup="NumberCheck(this)" placeholder="请输入提取数量">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">到账数量</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="test" id="dzNumebr" disabled placeholder="0.00">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">钱包地址</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="test" id="address" value="{$addr}" name="address" placeholder="请输入钱包地址">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">二级密码</label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="password" id="paypassword" name="paypassword" placeholder="请输入二级密码">
                    </div>
                </div>
            </div>
            <div class="weui-btn-area">
                <a href="javascript:void(0);" style="background-image: linear-gradient(250deg, #e62e2e 0%, #e62e2e 100%), linear-gradient(#e62e2e, #e62e2e) !important;box-shadow: 0.033333rem 0.058rem 0.133333rem 0 rgba(157, 157, 157, 0.3);border-radius: 42px;font-size: 0.2rem;height: 0.6rem;line-height: 0.6rem;border: solid 0.006667rem #e62e2e;" class="weui-btn weui-btn_primary" onclick="submits()">确定</a>
            </div>
        </form>
    </div>
</div>
<script>
    $(function() {
        FastClick.attach(document.body);
    });
</script>
<script>
    //监控提取数量，同步到账数量
    $('#tqNumber').bind("input propertychange",function(event){
        var num = $(this).val();
        num = num-10;
        $('#dzNumebr').val(num);
    })
    //提交前验证表单
    function submits() {
        var minners = $('#minners').val();
        var tqNumber = $('#tqNumber').val();
        var address = $('#address').val();
        var paypassword = $('#paypassword').val();

        if (tqNumber < 100) {
            showErrorMsg('提取数量不能小于100！');
            return false;
        }
      /*  if (tqNumber > minners){
            showErrorMsg('提取数量不能大于可提取数量！');
            return false;
        }*/
        if (address == '' ) {
            showErrorMsg('提转地址不能为空！');
            return false;
        }
        if (paypassword == '' ) {
            showErrorMsg('请输入二级密码！');
            return false;
        }

        $.ajax({
            url: "{:U('Member/ti_zhuan')}",
            type: 'post',
            dataType: 'json',
            data: $('#payform').serialize(),
            success: function (data) {
                if (data.code == 0) {
                    $.toast(data.msg, 2000, 'cancel');
                    window.location.href = "{:U('Member/index')}";
                } else {
                    showErrorMsg(data.msg);
                    return false;
                }
            }
        })
    }
    /**
     * 提示弹窗
     * */
    function showErrorMsg(msg) {
        $.toast(msg,'cancel');
    }

    //检查输入提取数量是否正确，只能输入数字和小数点
    function NumberCheck(obj) {
        //先把非数字的都替换掉，除了数字和.
        obj.value = obj.value.replace(/[^\d.]/g,"");
        //必须保证第一个为数字而不是.
        obj.value = obj.value.replace(/^\./g,"");
        //保证只有出现一个.而没有多个.
        obj.value = obj.value.replace(/\.{2,}/g,".");
        //保证.只出现一次，而不能出现两次以上
        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
    }
    $(function () {
        FastClick.attach(document.body);
    });
</script>
</body>
</html>
